<include file="../header" />
<body class="J_scroll_fixed">

<style type="text/css">
    .btn-danger,.btn-info,.btn-success,.btn-warning{
        width: 60px;
        /*height: 18px;*/
        padding: 2px 0px 2px 0px;
        margin: 1px 0px 1px 0px;
    }
</style>
<script type="text/javascript">
    function delCode(id, name, level) {
        if(level == 0){
            if(!confirm("删除【一级分类】将一同删除其所有子分类，是否删除【" + name +"】")){
                return false;
            }
        }else{
            if(!confirm("是否删除二级分类【" + name +"】")){
                return false;
            }
        }

        var url = "/admin/Code/remove?id=" + id;
        window.location.href = url;
    }
</script>
<form class="well form-search" method="post" style="float:left;width:100%;" action="{:U('Code/index')}">
    <div class="search_type cc mb10">
        <div class="mb10">
        <span class="mr20">
            一级分类：<input type="text" name="level0" value="{$level0}" />
            二级分类：<input type="text" name="level1" value="{$level1}" />
            <button class="btn btn-primary">搜索</button>
            <a class="btn" href="{:U('Code/index')}">重置</a>
        </span>
        </div>
    </div>
</form>
<div class="wrap J_check_wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:U('Code/index')}">编码信息</a></li>
        <li><a href="{:U('Code/add')}">新增编码</a></li>
    </ul>
    <table class="table table-hover table-bordered">
        <thead>
        <tr>
            <th style="min-width: 150px; width: 150px">一级分类</th>
            <th style="min-width: 150px; width: 150px">二级分类</th>
            <th style="min-width: 300px; width: 600px">备注</th>
            <th style="min-width: 100px; width: 100px">操作</th>
        </tr>
        </thead>
        <tbody>
        <foreach name="list0" item="vo0">
            <tr>
                <td style="font-weight: bold">{$vo0.name}</td>
                <td><a style="width: 120px" class="btn btn-info" href='{:U("Code/add",array("id"=>$vo0["code_id"]))}'>新增二级分类</a></td>
                <td style="white-space: pre-wrap">{$vo0.remark}</td>
                <td>
                    <a class="btn btn-info" href='{:U("Code/edit",array("id"=>$vo0["code_id"]))}'>修改</a>
                    <a class="btn btn-danger" onclick='javascript:delCode("{$vo0.code_id}","{$vo0.name}",0)'>删除</a>
                </td>
            </tr>
            <foreach name="list1" item="vo1">
                <if condition="$vo1['parentid'] eq $vo0['code_id']">
                    <tr>
                        <td></td>
                        <td>{$vo1.name}</td>
                        <td>{$vo1.remark}</td>
                        <td>
                            <a class="btn btn-info" href='{:U("Code/edit",array("id"=>$vo1["code_id"]))}'>修改</a>
                            <a class="btn btn-danger"  onclick='javascript:delCode("{$vo1.code_id}","{$vo1.name}",1)'>删除</a>
                        </td>
                    </tr>
                </if>
            </foreach>
        </foreach>
        </tbody>
    </table>
    <div class="pagination">{$page}</div>
</div>
<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>